﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data;

using PolePositionMobileUtilityGeneral;

namespace PolePositionMobileUtilityEntity
{
    public class EResultType : EBaseLookup
    {
        public EResultType()
            : base()
        {
            m_TableCollumnId = "ResultTypeId";
            m_TableName = "tb_ResultTypes";
        }
        public EResultType(int id, string name)
            : this()
        {
            Id = id;
            Name = name;
        }

        public EResultType[] GetAll()
        {
            DataTable _dt = SelectAll();
            EResultType[] arr = new EResultType[_dt.Rows.Count];
            for (int i = 0; i < _dt.Rows.Count; i++)
            {
                arr[i] = new EResultType(ConvertMobileHelper.ToInt32(_dt.Rows[i][m_TableCollumnId]), ConvertMobileHelper.Tostring(_dt.Rows[i][m_TableCollumnName]));
            }
            return arr;
        }

        public static int parseValue(string value)
        {
            int numberOne = 0;
            int numberTwo = 0;

            int _commaIndex = value.IndexOf("-");
            if (_commaIndex > -1)
            {
                numberOne = ConvertMobileHelper.ToInt32(value.Split('-')[0]) * 10;
                numberTwo = ConvertMobileHelper.ToInt32(value.Split('-')[1]);
                numberOne = numberOne + numberTwo;
            }
            else
            {
                numberOne = ConvertMobileHelper.ToInt32(value);
            }
            return numberOne;
        }
    }
}
